﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XEvents.Addin
{
    internal static class Utilities
    {
        internal static TreeNode GetParentNodeByLevel(TreeNode tn, int level)
        {
            if (level == tn.Level)
                return tn;

            if (level > tn.Level || tn.Parent == null)
                return null;

            TreeNode parent = tn.Parent;
            while (parent.Level > level)
            {
                parent = parent.Parent;
            }

            return parent;
        }

    }
}
